package com.ocom.human.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ocom.common.entity.master.EntityCompanyList;
import com.ocom.common.enums.DataSourceEnum;
import com.ocom.common.enums.MasterSlaveEnum;
import com.ocom.human.dao.IDaoCompanyList;
import com.ocom.human.service.CompanyListService;
import com.ocom.mysql.aspect.DataSourceAspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CompanyListServiceImpl extends ServiceImpl<IDaoCompanyList, EntityCompanyList> implements CompanyListService {

    @Autowired
    private IDaoCompanyList companyList;

    @DataSourceAspect(type = DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    @Override
    public EntityCompanyList selectById(Long comID) {
        return companyList.selectById(comID);
    }

    @Override
    @DataSourceAspect(type = DataSourceEnum.MAIN_DB,isMaster = MasterSlaveEnum.SLAVE)
    public List<EntityCompanyList> selectByIds(List<Long> comId) {
        QueryWrapper<EntityCompanyList> queryWrapper = Wrappers.query();
        queryWrapper.in("com_id", comId);
        return this.list(queryWrapper);
    }
}
